package com.example.tetris.logics.components;

import java.io.Serializable;

public final class Tetromino implements Serializable {
    private static final int[][][] SHAPE_O = {
            {
                    {0,0,0,0},
                    {0,1,1,0},
                    {0,1,1,0},
                    {0,0,0,0}
            },
    };
    private static final int[][][] SHAPE_I = {
            {
                    {0,0,0,0},
                    {1,1,1,1},
                    {0,0,0,0},
                    {0,0,0,0}
            },
            {
                    {0,0,1,0},
                    {0,0,1,0},
                    {0,0,1,0},
                    {0,0,1,0}
            },
    };
    private static final int[][][] SHAPE_S = {
            {
                    {0,0,0,0},
                    {0,0,1,1},
                    {0,1,1,0},
                    {0,0,0,0}
            },
            {
                    {0,0,1,0},
                    {0,0,1,1},
                    {0,0,0,1},
                    {0,0,0,0}
            },
    };
    private static final int[][][] SHAPE_Z = {
            {
                    {0,0,0,0},
                    {0,1,1,0},
                    {0,0,1,1},
                    {0,0,0,0}
            },
            {
                    {0,0,0,1},
                    {0,0,1,1},
                    {0,0,1,0},
                    {0,0,0,0}
            }
    };
    private static final int[][][] SHAPE_L = {
            {
                    {0,0,0,0},
                    {0,1,1,1},
                    {0,1,0,0},
                    {0,0,0,0}
            },
            {
                    {0,0,1,0},
                    {0,0,1,0},
                    {0,0,1,1},
                    {0,0,0,0}
            },
            {
                    {0,0,0,1},
                    {0,1,1,1},
                    {0,0,0,0},
                    {0,0,0,0}
            },
            {
                    {0,1,1,0},
                    {0,0,1,0},
                    {0,0,1,0},
                    {0,0,0,0}
            }

    };
    private static final int[][][] SHAPE_J = {
            {
                    {0, 0, 0, 0},
                    {0, 1, 1, 1},
                    {0, 0, 0, 1},
                    {0, 0, 0, 0}
            },
            {
                    {0, 0, 1, 1},
                    {0, 0, 1, 0},
                    {0, 0, 1, 0},
                    {0, 0, 0, 0}
            },
            {
                    {0, 1, 0, 0},
                    {0, 1, 1, 1},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0}
            },
            {
                    {0, 0, 1, 0},
                    {0, 0, 1, 0},
                    {0, 1, 1, 0},
                    {0, 0, 0, 0}
            }



    };
    private static final int[][][] SHAPE_T = {
            {
                    {0,0,0,0},
                    {0,1,1,1},
                    {0,0,1,0},
                    {0,0,0,0}
            },
            {
                    {0,0,1,0},
                    {0,0,1,1},
                    {0,0,1,0},
                    {0,0,0,0}
            },
            {
                    {0,0,1,0},
                    {0,1,1,1},
                    {0,0,0,0},
                    {0,0,0,0}
            },
            {
                    {0,0,1,0},
                    {0,1,1,0},
                    {0,0,1,0},
                    {0,0,0,0}
            },
    };

    public static int[][] getShape(final SHAPE shape, final int rotateType){
        return switch (shape) {
            case O -> SHAPE_O[rotateType % SHAPE_O.length];
            case I -> SHAPE_I[rotateType % SHAPE_I.length];
            case J -> SHAPE_J[rotateType % SHAPE_J.length];
            case L -> SHAPE_L[rotateType % SHAPE_L.length];
            case S -> SHAPE_S[rotateType % SHAPE_S.length];
            case T -> SHAPE_T[rotateType % SHAPE_T.length];
            case Z -> SHAPE_Z[rotateType % SHAPE_Z.length];
            default -> null;
        };

    }



}
